const app = getApp();
const req = require("../../utils/http.js");
Page({
  /**
   * 页面的初始数据
   */
  data: {
    selected: [],
    count: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let name = options.name
    wx.setNavigationBarTitle({
      title: name,
    })
    let params={}
    req.wxReq('/coupon/wxUser/selectListByOpenid','GET',params).then(res=>{
      console.log('000000',res)
      if(res.data.code==200){
        let date = [];
        for(let i of res.data.result){
          let setDate = i.signDate
          date.push({ date:setDate.substring(0,10)})
        }
        this.setData({
          selected:date,
          count:date.length
        })
      }else{
        wx.showToast({
          title: '加载失败请重试',
          duration: 2000,
        })
      }
    })
   
  },
  /**
   * 日历是否被打开
   */
  bindselect(e) {
    console.log(e.detail.ischeck)
  },
  /**
   * 获取选择日期
   */
  bindgetdate(e) {
    // let time = e.detail;
    // console.log(time)
  },
  //签到
  bindsign(e) {
    let oldSelected = this.data.selected;
    let date = new Date();
    let year = date.getFullYear();
    let mon = date.getMonth() + 1;
    let day = date.getDate();
    oldSelected.push({ date: year + '-' + mon + '-' + day })
    this.setData({
      selected: oldSelected,
      count: oldSelected.length
    })
  },
})